<?php defined('SEJUJOPEFDNGJSL') or exit('Access denied');?>
<?php
if(empty($_SESSION["checkscode"])||!strstr($_SESSION["checkscode"],'zhuanlist')){
    $_GET["m"]="zhuanlist";
    @require(ROOTTHEMETEMP."checkscode.inc.php");
    exit;
}
if(!isset($_GET['templist'])){
?>
    <?php require("topbut.php") ?>
    <div class="panel panel-inverse">
        <div class="panel-heading">
            <div class="row">
                <div class="col-md-12">
                    <h4 class="panel-title" style="float: left;">电子/消费劵转账</h4>
                    <a href="<?php echo $GLOBALARR['curl']?>&templist=1" style="color: #fff;float: right;">查看转账记录</a>
                </div>
            </div>
        </div>
        <div class="panel-body">
            <form action="control.php" method="post" onsubmit="return chkzhuan()">
                <input type="hidden" name="act" value="zhuan">
                <fieldset style="border:none;">
                    <script type="text/javascript">
                    zhuanmin=<?php echo $GLOBALARR['zhuanmin']?>;
                    </script>
                    <legend>注意：此操作点击确定后不可逆转，请仔细输入。</legend>
                    <div class="form-group">
                        <label for="exampleInputEmail1">转账类型</label>
                        <select class="form-control" name="ztype" id="ztype" >
                            <option value="-1">请选择转账类型</option>
                            <option value="0">商品积分</option>
                            <option value="1">消费劵</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="exampleInputEmail1">对方账号</label>
                        <input type="text" name="username" id="username" value="" class="form-control" onblur="getusername();" />
                        <span style="color:red;" id="ztxt"></span><span style="display:none;" id="did"></span>
                    </div>
                    <div class="form-group">
                        <label for="exampleInputEmail1">转账数量</label>
                        <input type="text" name="jine" id="jine" class="form-control" />
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">转账备注</label>
                        <textarea name="tbz" class="form-control"></textarea>
                    </div>
                    <div class="form-group">
                      <label for="exampleInputPassword1">验证码</label>
                        <input type="text" class="input-text yzmput form-control" name="coded" id="coded" />
                        <input type="hidden" name="mobile" id="mobile" value="<?php echo $r['phone']?>" class="form-control" readonly="readonly" />
                        <input type="button" id="btnSendCode" onclick="sendSms()" class="btn btn-md btn-danger" style="margin-top: 5px"; value="发送验证码" />
                    </div>
                    <button type="submit" class="btn btn-md btn-success m-r-5">确定</button>
                </fieldset>
            </form>
        </div>
    </div>
     <script type="text/javascript" src="/public/home/js/layer/layer.js"></script>
    <script type="text/javascript">
    var InterValObj; //timer变量，控制时间
    var count = 60; //间隔函数，1秒执行
    var curCount;//当前剩余秒数
    function sendSms(){
        $.ajaxSetup({
            async: false
        });
        var phone = $("#mobile").val();

         //两者格式都争取情况下可发送手机验证码
         curCount = count;
    　　//设置button效果，开始计时
         $("#btnSendCode").attr("disabled", "true");
         $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
         InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次

         $.ajax({
            type: "get",
            dataType: "json",
            url: "/plus/sendsms.php?phone="+phone,
            success: function(data){
                layer.alert(data.res);
            },
            error: function(){

            },
            cache: false,
            async: false
         });
    }
    //timer处理函数
    function SetRemainTime() {
        if(curCount == 0){
          window.clearInterval(InterValObj);//停止计时器
          $("#btnSendCode").removeAttr("disabled");//启用按钮
          $("#btnSendCode").val("重新发送验证码");
        }else{
           curCount--;
           $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
        }
    }
    </script>

<?php
}else{
?>
<?php require("topbut.php") ?>
    <div class="panel panel-inverse">
        <div class="panel-heading">
            <div class="row">
                <div class="col-md-12">
                    <h4 class="panel-title" style="float:left;">我的转账记录</h4>
                    <a href="<?php echo $GLOBALARR['curl']?>" style="color:#fff;float: right;">返回</a>
                </div>
            </div>
        </div>
        <div class="panel-body">
            <div class="selectbar">
                <span class="<?php echo empty($_GET['cointype']) ? "seld" : "" ?>"><a href="home.php?lsact=zhuanlist&templist=1&cointype=0">商品积分</a></span>
                <span class="<?php echo !empty($_GET['cointype']) && $_GET['cointype'] == 1 ? "seld" : "" ?>"><a href="home.php?lsact=zhuanlist&templist=1&cointype=1">消费劵</a></span>
            </div>
            <div class="table-responsive">
                <table class="table table-striped givetable">
                  <tbody>
                    <tr >
                        <th>序号</th>
                        <th>发送人</th>
                        <th>接收人</th>
                        <th>类型</th>
                        <th>转账金额</th>
                        <th>转账时间</th>
                        <th>备注</th>
                    </tr>
                <?php
                if(empty($_GET['cointype'])){
                    $ztype = 0;
                }else{
                    $ztype = 1;
                }
                $pagecount=10;
                $condition=" where (user_name='$_username' or uname='$_username') and ztype = ".$ztype;
                $psql="select count(0) from ld_transfer_accounts $condition";
                $db->query($psql,3);
                $pcount=$db->fval;
                $pagecount=$pagecount;   //每页条数
                $astr="&lsact=zhuanlist&templist=1&cointype=".$_GET['cointype'];    //Url
                $pagearr=pagelist($pagecount,$pcount,$astr);
                $offset=$pagearr[1];

                $sql="select * from ld_transfer_accounts $condition order by id desc limit $offset,$pagecount";
                $db->query($sql);
                $rs=$db->rs;
                $ii=0;
                foreach ($rs as $k => $v) {
                  $ii++;
                  $serialid=($pagearr[2]-1)*$pagecount+$ii;
                  if($v['user_name']==$_username){
                      $liuru='转出';

                    }
                   if($v['uname']==$_username){
                        $liuru='转入';
                    }
                ?>
                    <tr>
                        <td ><?php echo $serialid?></td>
                        <td><?php echo $v['user_name']?></td>
                        <td><?php echo $v['uname']?></td>
                        <td><?php echo $liuru;?></td>
                        <td><?php echo formatrmb($v['amount'])?>&nbsp;</td>
                        <td><?php echo formatdate($v['tran_time'],0)?></td>
                        <td><?php echo $v['tbz']?></td>
                    </tr>
                <?php
                }
                ?>
                  </tbody>
                </table>
            </div>
        </div>
    </div>
<!-- <div class="right_center">我的转账记录 <a href="<?php echo $GLOBALARR['curl']?>" style="color: red;">返回</a></div> -->

<?php if(($pcount/$pagecount)>1){?>
<div class="pagediv"><?php echo $pagearr[0]?></div>
<?php }?>
<?php if($pcount==0){?>
<div class="pagediv" style="text-align:center;color:#E47501">--> 暂无数据</div>

<?php
}
}
?>